using System;
using System.Collections.Generic;
using System.Text;

namespace Boids2D
{
    class Pseudocode
    {
        /*
        

    	initialise_positions()

        LOOP
	        draw_boids()
	        move_all_boids_to_new_positions()
        END LOOP




         
          
          
          
      	PROCEDURE move_all_boids_to_new_positions()

	        Vector2 v1, v2, v3
	        Boid b

	        FOR EACH BOID b
		        v1 = rule1(b)
		        v2 = rule2(b)
		        v3 = rule3(b)

		        b.velocity = b.velocity + v1 + v2 + v3
		        b.position = b.position + b.velocity
	        END

        END PROCEDURE


        //Rule 1: Boids try to fly towards the centre of mass of neighbouring boids. 
        PROCEDURE rule1(boid bIn)

	        Vector2 pcJ

	        FOR EACH BOID b
		        IF b != bIn THEN
			        pcJ = pcJ + b.position
		        END IF
	        END

	        pcJ = pcJ / N-1

	        RETURN (pcJ - bIn.position) / 100

        END PROCEDURE



        //Rule 2: Boids try to keep a small distance away from other objects (including other boids). 

        PROCEDURE rule2(boid bJ)

		    Vector2 c = 0;

		    FOR EACH BOID b
			    IF b != bJ THEN
				    IF |b.position - bJ.position| < 100 THEN
					    c = c - (b.position - bJ.position)
				    END IF
			    END IF
		    END

		    RETURN c

	    END PROCEDURE


        


        //Rule 3: Boids try to match velocity with near boids. 
        PROCEDURE rule3(boid bJ)

		    Vector2 pvJ

		    FOR EACH BOID b
			    IF b != bJ THEN
				    pvJ = pvJ + b.velocity
			    END IF
		    END

		    pvJ = pvJ / N-1

		    RETURN (pvJ - bJ.velocity) / 8

	    END PROCEDURE

        


        //Other possibilities

        //Action of a strong wind or current
        PROCEDURE strong_wind(Boid b)
            Vector2 wind

            RETURN wind
        END PROCEDURE

        //Tendency towards a particular place
        PROCEDURE tend_to_place(Boid b)
		    Vector2 place

		    RETURN (place - b.position) / 100
	    END PROCEDURE


        //Limiting the speed
        PROCEDURE limit_velocity(Boid b)
                Integer vlim
                Vector2 v

                IF |b.velocity| > vlim THEN
                        b.velocity = (b.velocity / |b.velocity|) * vlim
                END IF
        END PROCEDURE




        //Bounding the position
	    PROCEDURE bound_position(Boid b)
            Integer Xmin, Xmax, Ymin, Ymax, Zmin, Zmax
            Vector2 v

            IF b.position.x < Xmin THEN
                v.x = 10
            ELSE IF b.position.x > Xmax THEN
                v.x = -10
            END IF
            IF b.position.y < Ymin THEN
                v.y = 10
            ELSE IF b.position.y > Ymax THEN
                v.y = -10
            END IF
            IF b.position.z < Zmin THEN
                v.z = 10
            ELSE IF b.position.z > Zmax THEN
                v.z = -10
            END IF
    		
            RETURN v
        END PROCEDURE
        */
    }
}
